<#-- 导入模版定义文件-->
<#-- 卡密库存产品修改,添加 -->
<#include "../template/template_editPage.ftl">
<@edit title="商品操作">
    <#if product??&&(product.id)??>
        <#assign isEdit = true />
    <#else>
        <#assign isAdd = true />
    </#if>
<body class="input">
<script type="text/javascript">
    $().ready(function () {

        var $validateErrorContainer = $("#validateErrorContainer");
        var $validateErrorLabelContainer = $("#validateErrorContainer ul");
        var $validateForm = $("#validateForm");
        var $tab = $("#tab");

        // Tab效果
        $tab.tabs(".tabContent", {
            tabs:"input"
        });

        // 表单验证
        $validateForm.validate({
            errorContainer:$validateErrorContainer,
            errorLabelContainer:$validateErrorLabelContainer,
            wrapper:"li",
            errorClass:"validateError",
            ignoreTitle:true,
            rules:{
                /* "product.name":{
                    required:true
                },*/
                "strPrice":{
                    required:true,
                    number:true,
                    positively:true
                }
            },
            messages:{
                /*  "product.name":{
                    required:"请填写商品名称"
                },*/
                "strPrice":{
                    required:"请填写面值",
                    number:"请输入合法的数字！"
                }
            },
            submitHandler:function (form) {
                $(form).find(":submit").attr("disabled", true);
                form.submit();
            }
        });
		<#if actionErrors??&&(actionErrors?size > 0)>
			$.dialog({type: "warn", content: "<#list errorMessages as list>${list}<br></#list>",
			 modal: true, autoCloseTime: 3000});
		</#if>
    });
</script>
<div class="body">
    <div class="inputBar">
        <h1><span class="icon">&nbsp;</span><#if isAdd??>库存产品添加<#else>库存产品编辑</#if></h1>
    </div>
    <div style="display: none;" id="validateErrorContainer" class="validateErrorContainer">
        <div class="validateErrorTitle">以下信息填写有误,请重新填写</div>
        <ul></ul>
    </div>
    <form id="validateForm" class="validate" method="post"
          action="<#if isAdd??>${web_base}/recharge/system_product!doAdd.htm<#else>${web_base}/recharge/system_product!doEdit.htm</#if>">
        <table class="inputTable tabContent">
            <tr>
                <th>产品名称:<input type="hidden" name="product.id" value="<#if isEdit??>${(product.id)!}</#if>"></th>
                <td><input type="text"
                           class="formText {required: true<#if isAdd??>,remote:'system_product!checkProductName.htm', minlength: 2, maxlength: 200, messages: {required: '请输入产品名称!',remote: '产品名称已经存在!'}</#if>}"
                           name="product.name" value="${(product.name)!}"><label
                        class="requireField">*</label></td>
            </tr>
            <tr>
                <th>运营商:</th>
                <td><select name="product.operationCode">
                    <#if operationList??>
                        <#list operationList as obj>
                            <option value="${obj.code!}">${obj.name!}</option>
                        </#list>
                    </#if>
                </select><label
                        class="requireField">*</label></td>
            </tr>
            <tr>
                <th>面值:</th>
                <td><input type="text" class="formText" name="strPrice"
                           value="<#if product?? && (product.faceValue)??>${(product.faceValue)/1000}</#if>"><label
                        class="requireField">*</label></td>
            </tr>
            <tr style="display: none;">
                <th>号码类型:</th>
                <td><select id="" name="product.phoneType">
                    <#if phoTypeList?? && phoTypeList?size gt 0 >
                        <#list phoTypeList as obj>
                            <option value="${obj.code!}" <#if (obj.code)?? && obj.code=="01">
                                    selected="selected" </#if>>${obj.name!}</option>
                        </#list>
                    </#if>
                </select></td>
            </tr>
        <#-- 资源商不做
        <tr>
            <th>资源商:</th>
            <td>
                <select name="product" id="">
                    <#if stockSuppliersList??>
                        <#list stockSuppliersList as obj>
                            <option value="${obj.id!}">${obj.name!}</option>
                        </#list>
                    </#if>
                </select><label
                    class="requireField">*</label>
            </td>
        </tr>-->
            <tr>
                <th>说明:</th>
                <td><textarea class="formText" name="product.introduce"
                              style="height: 80px;width: 205px;">${(product.introduce)!}</textarea><label
                        class="requireField">*</label></td>
            </tr>
        </table>
        <div class="buttonArea">
            <input type="submit" class="formButton" value="<#if isAdd??>添加<#else>修改</#if>" hidefocus="true"/>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回"
                   hidefocus="true"/>
        </div>
    </form>
</div>
</body>

</@edit>